package edu.uta.cfl.GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Vector;
import java.util.regex.Pattern;

import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.text.Element;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

import net.coderazzi.filters.gui.AutoChoices;
import net.coderazzi.filters.gui.TableFilterHeader;
//import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
//import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
import edu.uta.cfl.console.CFL;
import edu.uta.cfl.data.Combo;
import edu.uta.cfl.data.IterationResult;
import edu.uta.cfl.data.Parameter;
import edu.uta.cfl.data.SUT;
import edu.uta.cfl.data.SUT.SUTState;
import edu.uta.cfl.engine.SUTInfoReader;
import edu.uta.cfl.engine.SUTInfoWriter;
import edu.uta.cfl.engine.SUTManager;
import edu.uta.cfl.util.Constants;

public class Gui {
	private static Gui instance;
	private JFrame frame;
	String testStrength = "0";
	String inputTestFile;
	String tempFile;
	String newTCFileLocation;
	String susComboFileLocation;
	String masterFileLocation; // added on 09/01/2014
	String sourceFileLocation;
	JTree tree;
	DefaultTreeModel treeModel;
	DefaultMutableTreeNode root;
	DefaultMutableTreeNode child; // added on 11/10/2014
	JPanel nsc_Panel;
	JPanel ntc_Panel;
	JTable nsc_JTable;
	JTable ntc_JTable;
	DefaultTableModel rtsTable;
	DefaultTableModel susTable;
	JTextArea masterFile_textArea;
	JTextArea sourceCodeFile_textArea;
	// RSyntaxTextArea sourceCode_textArea;
	JTextArea linenumber;
	String columnStr;
	public static SUT sut;
	public static int curCmbLen;
	public static int itr;
	boolean openedAlready = false;
	JTextField textField_IPM;
	JTextField textFieldPath_rts;
	JTextField textFieldFileName_rts;
	JTextField textField_projectName;
	JTextField textFieldPath_SC;
	JTextField textFieldFileName_SC;
	String rtc_Path;
	String rtc_fileName;
	String sc_Path;
	String sc_fileName;
	DefaultTableModel pTable = new DefaultTableModel();
	JTable parameterTable = new JTable(pTable);
	DefaultTableModel cTable = new DefaultTableModel();
	JTable constraintsTable = new JTable(cTable);
	DefaultTableModel testresultTable = new DefaultTableModel();
	JTable resultTable = new JTable(testresultTable);
	JButton initialBuildBtn = new JButton();
	JButton iterativeBuildBtn = new JButton();
	File selectedFile;
	Boolean validFile;
	String[] pnameArray;
	// DefaultMutableTreeNode parameters;
	StatusBar statusBar;
	JButton searchBtn = new JButton();
	TableFilterHeader susCombFilter = new TableFilterHeader();
	DefaultMutableTreeNode sourceCode = new DefaultMutableTreeNode(
			"Source Code");
	DefaultMutableTreeNode initialTestSet = new DefaultMutableTreeNode(
			"Initial Test Set");
	DefaultMutableTreeNode inputparametermodel = new DefaultMutableTreeNode(
			"Input Parameter Model");
	DefaultMutableTreeNode parameters = new DefaultMutableTreeNode("Parameters");
	DefaultMutableTreeNode constraints = new DefaultMutableTreeNode(
			"Constraints");
	DefaultMutableTreeNode masterFile = new DefaultMutableTreeNode(
			"Master File"); // added on 09/01/2014
	DefaultMutableTreeNode phase1 = new DefaultMutableTreeNode("Phase 1");
	JPanel susCombo_Panel; // added on 11/10/2014
	JTable susComponent_JTable;
	DefaultTableModel susComboTable;
	String susComponentsFileLocation;
	JButton infoHelpBtn = new JButton();
	ArrayList<String> recommendedTestSet = new ArrayList<String>();
	ArrayList<String> suspiciousCombination = new ArrayList<String>();
	int susComboSize;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					UIManager.setLookAndFeel(UIManager
							.getSystemLookAndFeelClassName()); // Set UI to
																// current
																// system
																// appearance
					// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
					// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
					// UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
					Gui window = Gui.getInstance();
					window.frame.setVisible(true);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Singleton Pattern - only one instance of GUI should be created!
	 *
	 */
	public static Gui getInstance() {
		if (instance == null) {
			instance = new Gui();
		}
		return instance;

	}

	/**
	 * Create the application.
	 */
	public Gui() {
		initialize();
	}

	@SuppressWarnings("static-access")
	public void initialize() {
		// Frame
		frame = new JFrame("");// Creating Frame
		frame.setSize(1000, 600); // setBounds(int x co-ordinate, int y
									// co-ordinate, int height, int width)
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JFrame.setDefaultLookAndFeelDecorated(true);
		frame.setLocationRelativeTo(null); // to position the window center on
											// the screen
		frame.setTitle("BEN");
		frame.setLayout(new BorderLayout());
		frame.setVisible(true);
		// Variables
		// Menu Bar Components
		JMenuBar menuBar = new JMenuBar();
		JMenu fileMenu = new JMenu(" File");
		JMenu helpMenu = new JMenu(" Help");
		JMenu editMenu = new JMenu(" Edit"); // added on 11/09/2014
		JMenu filterMenu = new JMenu(" Filter");
		JMenuItem fileOpen = new JMenuItem();
		JMenuItem fileOpen_MasterFile = new JMenuItem();
		JMenuItem fileExit = new JMenuItem();
		JMenuItem helpAbout = new JMenuItem();
		JMenuItem resetFilter = new JMenuItem("Reset Filter"); // added on
																// 11/09/2014
		final String aboutApplication = "Version 1.0";

		// ToolBar Components
		JToolBar toolBar = new JToolBar();
		JButton openFileBtn = new JButton();
		JButton newFileBtn = new JButton();
		// JButton infoHelpBtn = new JButton();

		// Right Panel components
		final JPanel sourceCodePanel = new JPanel();
		final JPanel initialTestSetPanel = new JPanel();

		// Create new Project Interface - 09/09/2014
		final JPanel createProjectPanel = new JPanel();
		JPanel projectName_Panel = new JPanel();
		JPanel ipmName_Panel = new JPanel();
		JPanel recommendedTest_Panel = new JPanel();
		// JPanel susCombo_Panel = new JPanel();

		// Componenets used in new Project Interface
		JLabel lblProjectName = new JLabel("Project Name:");

		JLabel lblinputName = new JLabel("IPM & Initial Test Set");

		textField_IPM = new JTextField();
		textField_IPM.setColumns(10);

		JButton btnOpen_inputFile = new JButton("Select Input File");
		JButton btnOpen_sourceFile = new JButton("Select Source code file"); // added
																				// on
																				// 09/24/2014
		JSeparator separator = new JSeparator();

		JSeparator separator_1 = new JSeparator();

		JLabel lblRecomTestSet = new JLabel("Recommended Test Set");

		textFieldPath_rts = new JTextField();
		textFieldPath_rts.setColumns(10);

		textFieldFileName_rts = new JTextField();
		textFieldFileName_rts.setColumns(10);

		textField_projectName = new JTextField();
		textField_projectName.setColumns(10);

		JLabel lblPath_rts = new JLabel("Path:");

		JLabel lblfileName_rts = new JLabel("File Name");

		JLabel lblSuspiciousCombinations = new JLabel("Suspicious Combinations");

		JLabel lblPath_SC = new JLabel("Path:");

		JLabel lblFileName_SC = new JLabel("File Name:");

		textFieldPath_SC = new JTextField();
		textFieldPath_SC.setColumns(10);

		textFieldFileName_SC = new JTextField();
		textFieldFileName_SC.setColumns(10);

		JButton btnPathBtn_rts = new JButton("Select Path");

		JButton btnPath_SC = new JButton("Select Path");

		final JPanel masterfilePanel = new JPanel(); // new panel added on
														// 09/01/2014
		masterfilePanel.setLayout(new BorderLayout());

		JLabel sourceCodeLabel = new JLabel("Source code");
		sourceCodePanel.setLayout(new BorderLayout());

		final JTabbedPane mainTab = new JTabbedPane();
		final JTabbedPane innerSpecificationTab = new JTabbedPane();
		mainTab.add("Source Code", sourceCodePanel);

		// mainTab.add("Input Parameter Model",innerSpecificationTab);
		// mainTab.add("Initial Test Set",initialTestSetPanel);
		// innerSpecificationTab.setBorder(BorderFactory.createCompoundBorder((BorderFactory.createRaisedBevelBorder()),
		// (BorderFactory.createLoweredBevelBorder())));
		innerSpecificationTab.setBorder(BorderFactory.createEmptyBorder(10, 10,
				10, 10));
		sourceCodePanel.add(sourceCodeLabel);

		initialTestSetPanel.setBorder(BorderFactory
				.createTitledBorder("Strength of the Test Set:     "));

		// Panel
		JPanel leftPanel = new JPanel();
		JPanel rightPanel = new JPanel();

		// Panels declarations for Constraints, Parameters and input test case
		// view
		final JPanel parameterPanel = new JPanel();
		parameterPanel.setLayout(new BorderLayout());
		final JPanel constraintsPanel = new JPanel();
		constraintsPanel.setLayout(new BorderLayout());
		initialTestSetPanel.setLayout(new BorderLayout());

		// Table logic

		parameterTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

		pnameArray = new String[2]; // Declaring string array
		pnameArray[0] = "Parameter Name"; // initializing the array elements
											// individually
		pnameArray[1] = "Parameter Value";

		// TextArea declaration for Master file

		masterFile_textArea = new JTextArea();
		masterFile_textArea.setEditable(false);
		// masterFile_textArea.setText("Testing Text");
		masterFile_textArea.setLineWrap(true);
		masterFile_textArea.setWrapStyleWord(true);

		// TextArea declaration for source code file

		sourceCodeFile_textArea = new JTextArea();
		sourceCodeFile_textArea.setEditable(false);
		sourceCodeFile_textArea.setLineWrap(true);
		sourceCodeFile_textArea.setWrapStyleWord(true);

		linenumber = new JTextArea();
		linenumber.setBackground(Color.LIGHT_GRAY);
		linenumber.setEditable(false);

		sourceCodeFile_textArea.getDocument().addDocumentListener(
				new DocumentListener() {

					public String getText() {
						int linePosition = sourceCodeFile_textArea
								.getDocument().getLength();
						Element root = sourceCodeFile_textArea.getDocument()
								.getDefaultRootElement();
						String text = "1"
								+ System.getProperty("line.separator");
						for (int i = 2; i < root.getElementIndex(linePosition) + 2; i++) {
							text += i + System.getProperty("line.separator");
						}
						return text;
					}

					@Override
					public void insertUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}

					@Override
					public void removeUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}

					@Override
					public void changedUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}
				});

		// ScrollPane declaration
		final JScrollPane parameterPane = new JScrollPane(parameterTable);
		parameterPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		parameterPane
				.setViewportBorder(new CompoundBorder(new CompoundBorder(null,
						new EtchedBorder(EtchedBorder.LOWERED, null, null)),
						null));
		parameterPane.setToolTipText("Parameters and Values");

		final JScrollPane constraintsPane = new JScrollPane(constraintsTable);
		constraintsPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		constraintsPane.setToolTipText("Constraints");

		JScrollPane initialTestPane = new JScrollPane(resultTable);
		initialTestPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		initialTestPane.setToolTipText("Initial Test Set");
		initialTestPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10,
				10));

		JScrollPane masterFilePane = new JScrollPane(masterFile_textArea);
		masterFilePane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		masterFilePane.setToolTipText("Master file for the Project");

		// RTextArea implementation begins
		// sourceCode_textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
		// sourceCode_textArea.setCodeFoldingEnabled(true);
		// sourceCode_textArea.setAntiAliasingEnabled(true);
		// RTextScrollPane sourceCodeFilePane = new
		// RTextScrollPane(sourceCode_textArea);
		// RTextArea implementation ends

		// Commenting the existing code for the implementation of RTextArea
		JScrollPane sourceCodeFilePane = new JScrollPane();
		sourceCodeFilePane.getViewport().add(sourceCodeFile_textArea);
		sourceCodeFilePane.setRowHeaderView(linenumber);
		sourceCodeFilePane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		sourceCodeFilePane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		sourceCodeFilePane.setToolTipText("Source code");

		parameterPanel.add(parameterPane);
		parameterPanel.setSize(200, 100);
		// parameterPanel.setBorder(BorderFactory.createTitledBorder("Parameters"));

		constraintsPanel.add(constraintsPane);
		constraintsPanel.setSize(200, 100);
		// constraintsPanel.setBorder(BorderFactory.createTitledBorder("Constraints"));

		innerSpecificationTab.add("Parameters", parameterPanel);
		innerSpecificationTab.add("Constraints", constraintsPanel);

		initialTestSetPanel.add(initialTestPane);

		sourceCodePanel.add(sourceCodeFilePane);
		masterfilePanel.add(masterFilePane);

		// Left panel components
		JLabel treeHeaderLabel = new JLabel();
		final String projectName_tree = "Project";
		root = new DefaultMutableTreeNode(projectName_tree);
		treeModel = new DefaultTreeModel(root);

		tree = new JTree(treeModel);

		// JSplitPane
		JSplitPane splitPane = new JSplitPane();
		splitPane.setDividerLocation(180);
		splitPane.setDividerSize(3);
		splitPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); // Empty
																				// border
																				// for
																				// the
																				// split
																				// pane

		// Definition Logic

		// Menu items definition logic
		fileOpen.setText(" Create New Project ...");
		// fileOpen.setIcon(new
		// javax.swing.ImageIcon(getClass().getResource("cse/uta/edu/Images/open_project_16.png")));
		// fileOpen.setIcon(getClass().getResource("cse/uta/edu/Images/open_project_16.png"));
		fileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_O,
				java.awt.event.InputEvent.CTRL_MASK));
		fileOpen.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				int optionSelected = JOptionPane.YES_NO_OPTION;

				System.out.println("Testing:  " + openedAlready);
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						startNewProject();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					System.out.println("Testing:  " + openedAlready);
					startNewProject();
					statusBar.setMessage("Success...");
				}

			}
		});
		fileOpen.setToolTipText("Click to open the Project");

		// New menu item added on 09/01/2014 - Open Existing Master File

		fileOpen_MasterFile.setText("Load Project ...");
		fileOpen_MasterFile.addActionListener(new ActionListener() {

			// **** 09/01/2014
			@Override
			public void actionPerformed(ActionEvent arg0) {
				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						openMasterFile();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					openMasterFile();
				}

			}

		});
		// Jagan test code ends here - 09/01/2014
		fileExit.setText(" Exit");
		// fileExit.setIcon(new
		// javax.swing.ImageIcon(getClass().getResource("cse/uta/edu/Images/exit.png")));
		fileExit.setToolTipText("Exit the Application");
		fileExit.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);

			}
		});

		helpAbout.setText(" About");
		helpAbout.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {

				JOptionPane.showMessageDialog(frame, aboutApplication);

			}
		});

		resetFilter.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				susCombFilter.resetFilter();

			}
		});
		// adding the menu items to menu
		fileMenu.add(fileOpen);
		fileMenu.add(fileOpen_MasterFile);
		fileMenu.addSeparator();
		fileMenu.add(fileExit);
		helpMenu.add(helpAbout);
		filterMenu.add(resetFilter);
		editMenu.add(filterMenu);
		fileMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		helpMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		editMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		// adding menu to menu bar
		menuBar.add(fileMenu);
		menuBar.add(editMenu);
		menuBar.add(helpMenu);

		// addding menubar to the window
		frame.setJMenuBar(menuBar);

		// ToolBar Components
		toolBar.setFloatable(false);

		openFileBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/open_project_24.png")));
		openFileBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		newFileBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/new_project_24.png")));
		newFileBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		infoHelpBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/help2.jpg")));
		infoHelpBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		initialBuildBtn.setIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/cse/uta/edu/Images/build_now_tb.png")));
		initialBuildBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(
				1, 1, 1, 4));
		initialBuildBtn.setEnabled(false);
		initialBuildBtn.setToolTipText("Initial iteration");

		iterativeBuildBtn.setIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/cse/uta/edu/Images/build_project_24.png")));
		iterativeBuildBtn.setBorder(javax.swing.BorderFactory
				.createEmptyBorder(1, 1, 1, 4));
		iterativeBuildBtn.setEnabled(false);
		iterativeBuildBtn.setToolTipText("Next iteration");
		searchBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/search_16.png")));
		searchBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4)); // added on 11/06/2014
		searchBtn.setEnabled(false);
		searchBtn.setToolTipText("Search for a Suspicious Combination");

		toolBar.addSeparator();
		toolBar.add(newFileBtn);
		toolBar.add(openFileBtn);
		toolBar.add(initialBuildBtn);
		toolBar.add(iterativeBuildBtn);
		toolBar.add(searchBtn); // added on 11/06/2014
		toolBar.add(infoHelpBtn);

		// LeftPanel components definitions
		treeHeaderLabel.setText("System View");
		treeHeaderLabel.setHorizontalAlignment(SwingConstants.CENTER);
		treeHeaderLabel.setBorder(new CompoundBorder(BorderFactory
				.createBevelBorder(BevelBorder.RAISED), new EmptyBorder(5, 5,
				5, 5)));

		/*
		 * to be implemented later GroupLayout layout = new
		 * GroupLayout(leftPanel); leftPanel.setLayout(layout);
		 */

		// Tree to Tab reflection logic -- when a node is selected on Tree,
		// corresponding tab will become active
		tree.addTreeSelectionListener(new TreeSelectionListener() {

			@Override
			public void valueChanged(TreeSelectionEvent e) {
				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
						.getLastSelectedPathComponent();

				if (selectedNode.isLeaf()) {
					String nodeSelected = selectedNode.toString();
					if (nodeSelected == "Source Code") {
						mainTab.removeAll();
						mainTab.add("Source Code", sourceCodePanel);
						loadSourceCode(sourceFileLocation);
						statusBar.setMessage("Viewing Source Code");
					}
					if (nodeSelected == "Initial Test Set") {
						mainTab.removeAll();
						mainTab.add("Initial Test Set", initialTestSetPanel);
						statusBar.setMessage("Initial Test Set");
					}

					if (nodeSelected == "Parameters") {
						mainTab.removeAll();
						mainTab.add("Input Parameter Model",
								innerSpecificationTab);
						// innerSpecificationTab.setSelectedIndex(0);
						innerSpecificationTab.removeAll();
						innerSpecificationTab.add("Parameters", parameterPanel);
						statusBar.setMessage("Parameters");

					}

					if (nodeSelected == "Constraints") {
						mainTab.removeAll();
						mainTab.add("Input Parameter Model",
								innerSpecificationTab);
						// innerSpecificationTab.setSelectedIndex(1);
						innerSpecificationTab.removeAll();
						innerSpecificationTab.add("Constraints",
								constraintsPanel);
						statusBar.setMessage("Constraints");
					}
					if (nodeSelected == "Suspicious Combination") {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", ntc_Panel);
						statusBar.setMessage("Recommended Test Case");
					}
					if (nodeSelected == "Master File") {
						mainTab.removeAll();
						mainTab.add("Master File", masterfilePanel); // added on
																		// 09/01/2014
						loadMasterFile(masterFileLocation);
						statusBar.setMessage("Project Information File");
					}
					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susCombo_Panel);
						statusBar.setMessage("Suspicious Components");
					}

				} // end of leaf!

			}
		});

		// Introducing StatusBar
		statusBar = new StatusBar();
		JPanel statusPanel = new JPanel();
		statusPanel.setLayout(new BorderLayout());
		statusPanel.add(statusBar, BorderLayout.WEST); // aligning the status
														// Message to the left
														// side of the screen
		statusPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createRaisedBevelBorder(),
				BorderFactory.createLoweredBevelBorder()));

		// aligning the elements on screen starts

		// leftPanel.add(treeHeaderLabel,BorderLayout.NORTH);
		leftPanel.setLayout(new BorderLayout());
		leftPanel.add(tree, BorderLayout.CENTER);

		splitPane.setLeftComponent(leftPanel);
		splitPane.setRightComponent(mainTab);

		frame.add(toolBar, BorderLayout.NORTH);
		frame.add(splitPane, BorderLayout.CENTER);
		frame.add(statusPanel, BorderLayout.SOUTH);
		// aligning the elements on screen ends

		// GUI Part ends

		// new interface logic starts
		newFileBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {

				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						startNewProject();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					startNewProject();
				}
			}
		});

		// new interface logic ends

		// logic testing starts
		infoHelpBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				firstIteration();

			}
		});
		// logic testing ends

		// functionality part begins
		openFileBtn.addActionListener(new ActionListener() {
			@SuppressWarnings("serial")
			@Override
			public void actionPerformed(ActionEvent e) {

				JFileChooser f1 = new JFileChooser();

				ArrayList<String> parameters_name = new ArrayList<String>();
				ArrayList<String> parameters_value = new ArrayList<String>();
				ArrayList<String> testResult_value = new ArrayList<String>();
				ArrayList<String> testResults = new ArrayList<String>();
				ArrayList<Parameter> parameters_initialForm = new ArrayList<Parameter>();
				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						openMasterFile();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					openMasterFile();
				}
			} // end of if loop openedAlready
		});

		initialBuildBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				statusBar.setMessage("Running Iteration 1"); // updating the
																// status bar
				// Call for first iteration
				initialLoad();
				int count = 1;
				modifyTree(count);
				// updateGUI(susComboFileLocation, newTCFileLocation);
				// displayInfo();
				// continueIteration();
				// updateMasterFile_results(count,
				// masterFileLocation,newTCFileLocation, susComboFileLocation);
				initialBuildBtn.setEnabled(false);
				iterativeBuildBtn.setEnabled(true);

			}
		});

		iterativeBuildBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				toContinueIteration();
			}
		});

	} // end of initialize() method

	protected void firstIteration() {
	}

	protected void toContinueIteration() {
		int optionSelected = JOptionPane.YES_NO_OPTION;

		int optionChoosen = JOptionPane.showConfirmDialog(frame,
				"Do You Want to continue with the next iteration?",
				"Confirm Close", optionSelected);
		if (optionChoosen == JOptionPane.NO_OPTION) {

			System.out
					.println("you have selected not to Continue with the next iteration");
			susComponentsFileLocation = susComboFileLocation.substring(0,
					susComboFileLocation.lastIndexOf(File.separator) + 1)
					+ "cmb.txt";
			System.out.println("The Combination File Location:"
					+ susComponentsFileLocation);
			System.out.println("Testing sut, curCmbLen values: " + sut + " "
					+ curCmbLen);
			(new SUTInfoWriter(susComponentsFileLocation)).printSuspiciousness(
					sut, curCmbLen);

			// adding the component child to the tree
			DefaultMutableTreeNode susComponents = new DefaultMutableTreeNode(
					"Suspicious Components");
			treeModel.insertNodeInto(susComponents, child,
					child.getChildCount());
			tree.setSelectionPath(new TreePath(susComponents));

			// adding the component panel
			/*
			 * // Table for componenets susComboTable = new DefaultTableModel();
			 * susComponent_JTable = new JTable(susComboTable);
			 *
			 * JScrollPane susCombo_ScrollPane = new
			 * JScrollPane(susComponent_JTable); susCombo_ScrollPane
			 * .setHorizontalScrollBarPolicy
			 * (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
			 *
			 *
			 * // Panel for New Test Case susCombo_Panel = new JPanel();
			 * susCombo_Panel.setLayout(new BorderLayout());
			 * susCombo_Panel.add(susCombo_ScrollPane);
			 *
			 * loadSusCombo(susComponentsFileLocation);
			 */

		}
		if (optionChoosen == JOptionPane.YES_OPTION) {
			System.out
					.println("you have selected to continue with the iteration");

		}

	}

	protected void loadSusCombo(IterationResult itr) {

		susComboHeader();
		susComboRow(itr);
		new TableDecorator(susComponent_JTable).updateTableUI();
		susComponent_JTable.setEnabled(false);

	}

	protected void startNewProject() {
		/*
		 * NewProject_Dialog window = new NewProject_Dialog();
		 * window.setVisible(true); Boolean status = false; status =
		 * window.getFileReadSuccess();
		 *
		 * if (status == true) { statusBar.setMessage("Success..."); String
		 * projectName = window.getProjectName(); String inputFileLocation =
		 * window.getInputFileLocation(); String rts_Path =
		 * window.getRts_PathName(); String sc_Path = window.getSc_PathName();
		 * String rts_FileName = window.getRts_FileName(); String sc_FileName =
		 * window.getSc_FileName(); String masterFile_Directory =
		 * window.getDirName(); // IPM's directory to create the master file
		 *
		 * updateTreeRoot(projectName);
		 *
		 * masterFileLocation =
		 * masterFile_Directory+File.separator+"masterFile.txt";
		 * newTCFileLocation = rts_Path + File.separator+rts_FileName+".txt";
		 * susComboFileLocation = sc_Path + File.separator+sc_FileName+".txt";
		 * System.out.println("Jagan testing:"+masterFileLocation); // for
		 * testing to be removed later createMasterFile(masterFileLocation);
		 * loadInputFile(inputFileLocation, rts_Path,
		 * sc_Path,rts_FileName,sc_FileName);
		 * updateMasterFile(masterFileLocation, inputFileLocation,
		 * newTCFileLocation,susComboFileLocation,projectName );
		 */
		NewProject_Dialog window = new NewProject_Dialog();
		window.setVisible(true);
		Boolean status = false;
		status = window.getFileReadSuccess();

		if (status == true) {

			String projectName_tree = window.getProjectName();
			String inputFileLocation = window.getInputFileLocation();
			String rts_Path = window.getRts_PathName();
			String sc_Path = window.getSc_PathName();
			String rts_FileName = window.getRts_FileName();
			String sc_FileName = window.getSc_FileName();
			String masterFile_Directory = window.getDirName(); // IPM's
																// directory to
																// create the
																// master file
			sourceFileLocation = window.getSourceCodeFileLocation();
			newTCFileLocation = rts_Path + File.separator + rts_FileName
					+ ".txt";
			susComboFileLocation = sc_Path + File.separator + sc_FileName
					+ ".txt";
			masterFileLocation = masterFile_Directory + File.separator
					+ "masterFile.txt";

			updateTree();
			updateTreeRoot(projectName_tree);
			createMasterFile(masterFileLocation);
			loadInputFile(inputFileLocation, rts_Path, sc_Path, rts_FileName,
					sc_FileName);
			updateMasterFile(masterFileLocation, inputFileLocation,
					newTCFileLocation, susComboFileLocation, projectName_tree,
					sourceFileLocation);
		}
	}

	private void updateTree() {
		// TODO Auto-generated method stub

		root.add(masterFile); // added on 09/01/2014
		root.add(sourceCode);
		root.add(inputparametermodel);
		root.add(initialTestSet);
		inputparametermodel.add(parameters);
		inputparametermodel.add(constraints);
		tree.getSelectionModel().setSelectionMode(
				TreeSelectionModel.SINGLE_TREE_SELECTION);
		tree.setShowsRootHandles(true);

	}

	@SuppressWarnings("serial")
	protected void openMasterFile() {

		ArrayList<String> parameters_name = new ArrayList<String>();
		ArrayList<String> parameters_value = new ArrayList<String>();
		ArrayList<String> testResult_value = new ArrayList<String>();
		ArrayList<String> testResults = new ArrayList<String>();
		ArrayList<Parameter> parameters_initialForm = new ArrayList<Parameter>();

		selectFile();
		ValidateInputFile validateObject = new ValidateInputFile();
		validFile = validateObject.ValidFile(selectedFile);

		if (validFile == false) {
			JOptionPane.showMessageDialog(null, "Invalid File", "Error",
					JOptionPane.ERROR_MESSAGE);
			statusBar.setMessage("Invalid File");
		}

		if (validFile == true) {

			statusBar
					.setMessage("Valid Master File.... Reading the information....");
			inputTestFile = validateObject.getIpmfile_Location();
			masterFileLocation = selectedFile.getPath();
			sourceFileLocation = validateObject.getSourceCodeLocation();

			System.out.println("Master File Location:" + masterFileLocation);
			// createMasterFile(masterFileLocation);
			susComboFileLocation = validateObject.getSc_Location();
			newTCFileLocation = validateObject.getRts_Location();
			String projectName = validateObject.getProject_Name();
			/*
			 * newTCFileLocation = f1.getCurrentDirectory().toString() +
			 * "//newTC.txt"; susComboFileLocation = f1.getCurrentDirectory()
			 * .toString() + "//newSusCombo.txt"; masterFileLocation =
			 * f1.getCurrentDirectory() .toString() + "//masterFile.txt";
			 * createMasterFile(masterFileLocation);
			 */
			sut = new SUT();
			sut = (new SUTInfoReader(inputTestFile)).getSUT();
			// updateMasterFile(masterFileLocation, inputTestFile);
			// Obtaining information from SUTInfoReader.java file
			// starts
			// new testing starts

			curCmbLen = sut.getStrength();
			SUTManager
					.approach(sut, sut.getStrength(), Constants.APPROACH_LOAD);

			// approachState = Constants.APPROACH_ADD;
			ArrayList<int[]> tcList = new ArrayList<int[]>();

			if (sut.getStatus() == SUTState.expansion) {
				sut.setStatus(SUTState.expansion);
				int len = curCmbLen;
				while ((sut.getStatus() == SUTState.expansion)
						&& len < Constants.maxIndStr - 1)
					SUTManager.expandCmb(sut, len++);

				curCmbLen = len;

				if (len < Constants.maxIndStr - 1)
					tcList = SUTManager.generateNewTC(sut, curCmbLen);
				else
					sut.setStatus(SUTState.notFound);

				itr = 0;
			} else
				tcList = SUTManager.generateNewTC(sut, sut.getStrength());
			System.out.println("*******" + sut.getStatus().toString());
			if (sut.getStatus() == SUTState.continuing) {
				printTCList(tcList, sut.getParameters());
				printSUT(sut, curCmbLen);
			} else {
				// (new SUTInfoWriter(outSpc)).printSUT(sut, curCmbLen);
				// (new SUTInfoWriter(
				// outSpc.substring(0, outSpc.lastIndexOf("\\") + 1)
				// + "cmp.txt")).printSuspiciousness(sut, curCmbLen);
			}

			// printOutput(sut.getStatus(), outTestset);

			// new testing ends

			updateTree();
			updateTreeRoot(projectName);
			// Parameters
			parameters_initialForm = sut.getParameters();
			for (Parameter p : parameters_initialForm) {
				parameters_name.add(p.getName());
				parameters_value.add(p.getValues().toString());
			}

			// Testing starts for printing the initial test result
			// column name
			String output = "";
			for (Parameter prm : parameters_initialForm)
				output += prm.getName() + ", ";
			String testSet_columnHeader = "[" + output + "]";
			System.out.println("Testing now ..." + output);
			// Testing ends
			// Updating the Parameters table

			pTable.setColumnCount(0);
			pTable.setRowCount(0);

			for (int col = 0; col < pnameArray.length; col++) {
				pTable.addColumn(pnameArray[col]);
			}

			for (int row = 0; row < parameters_name.size(); row++) {
				pTable.insertRow(row, new Object[] { parameters_name.get(row),
						parameters_value.get(row) });
			}

			// logic to update the UI of parameter table starts
			parameterTable.setDefaultRenderer(Object.class,
					new TableCellRenderer() {
						private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();

						@Override
						public Component getTableCellRendererComponent(
								JTable table, Object value, boolean isSelected,
								boolean hasFocus, int row, int column) {
							Component c = DEFAULT_RENDERER
									.getTableCellRendererComponent(table,
											value, isSelected, hasFocus, row,
											column);
							if (row % 2 == 0) {
								c.setBackground(Color.WHITE);
							} else {
								c.setBackground(Color.LIGHT_GRAY);
							}
							return c;
						}

					});
			parameterTable.setEnabled(false); // non - editable parameter table

			// logic to update the UI of parameter table ends.
			// Updating the Constraints Table
			String[] columnName = { "Constraints" };
			cTable.setColumnCount(0);
			cTable.setRowCount(0);

			for (int col = 0; col < columnName.length; col++) {
				cTable.addColumn(columnName[col]);
			}

			for (int r = 0; r < sut.getConstraints().size(); r++) {
				cTable.insertRow(r,
						new Object[] { sut.getConstraints().get(r) });
			}

			constraintsTable.setEnabled(false); // non - editable constraints
												// table

			// initial test set with results
			testresultTable.setColumnCount(0);
			testresultTable.setRowCount(0);

			// Initial Test Result column calculation

			ArrayList<String> testDataColumnName = new ArrayList<String>();
			int count_new = 0;
			for (Parameter prm : parameters_initialForm)

			{
				// System.out.println("hehehehehe  "+count_new+"  the value is  "+prm.getName());
				testDataColumnName.add(count_new, prm.getName());
				count_new++;
			}

			testDataColumnName.add("Result");

			// calculating test data results
			int testResultSize = sut.getTs().getResult().size();

			for (int count = 0; count < testResultSize; count++) {

				testResult_value.add(sut.getTs().getResult().get(count)
						.toString());
			}

			for (int count = 0; count < testResult_value.size(); count++) {
				String pass = "Pass";
				String fail = "fail";
				System.out.println("Count :" + count + "   Value :"
						+ testResult_value.get(count).toString());

				if (testResult_value.get(count).toString()
						.equalsIgnoreCase("1")) {
					testResults.add(count, pass);
					System.out.println("testing: pass loop  "
							+ testResults.size());
				} else if (testResult_value.get(count).toString()
						.equalsIgnoreCase("0")) {
					testResults.add(count, fail);
					System.out.println("testing:fail loop  "
							+ testResults.size());
				}
			}

			System.out.println("testing:   " + testResults.size());
			// updating the table
			for (int col = 0; col < testDataColumnName.size(); col++) {
				testresultTable.addColumn(testDataColumnName.get(col));
			}

			ArrayList<String> testData = new ArrayList<String>();
			int testArray = sut.getTs().getMatrix().size();
			System.out.println("Jagan testing ..." + testArray + "\n"
					+ Arrays.toString(sut.getTs().getMatrix().get(1)));
			String a = Arrays.toString(sut.getTs().getMatrix().get(1));
			String arrayString[] = new String[testArray];
			System.out.println("Jagan testing .... round 2" + a);

			for (int i = 0; i < testArray; i++) {
				arrayString[i] = Arrays
						.toString(sut.getTs().getMatrix().get(i));
			}
			int rowCount = 0;

			for (String k : arrayString) {
				k = k.replace("[", "");
				k = k.replace("]", "");
				// int count_string =1;
				Pattern paramPattern = Pattern.compile(",");
				String[] tokens = paramPattern.split(k);
				ArrayList<String> jaganTest = new ArrayList<String>();

				for (int i = 0; i < tokens.length; i++) {
					jaganTest.add(tokens[i]);
					System.out.println("Printing data from ...."
							+ jaganTest.size() + "\n");

				}

				jaganTest.add(testResults.get(rowCount)); // adding
															// results
															// to
															// the
															// List

				/*
				 * System.out.println("\n==> Iterator Example...new") ;
				 * Iterator<String> testIterator1 = jaganTest.iterator(); while
				 * (testIterator1.hasNext()) {
				 * System.out.println(testIterator1.next()); }
				 */
				// System.out.println("testing"+tokens.length);

				Vector<Object> row1 = new Vector<Object>();
				int count = 1;
				// logic to update the vector object
				// for(int i=0;i<tokens.length;i++)
				for (int i = 0; i < jaganTest.size(); i++) {
					// row1.add(tokens[i]);
					row1.add(jaganTest.get(i));
					System.out.println("Row #: " + count);
					// System.out.println(tokens[i]);
					count++;
				}

				testresultTable.addRow(row1);
				// added on 09/12/2014 - to
				resultTable.setDefaultRenderer(Object.class,
						new TableCellRenderer() {
							private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();

							@Override
							public Component getTableCellRendererComponent(
									JTable table, Object value,
									boolean isSelected, boolean hasFocus,
									int row, int column) {
								Component c = DEFAULT_RENDERER
										.getTableCellRendererComponent(table,
												value, isSelected, hasFocus,
												row, column);
								if (row % 2 == 0) {
									c.setBackground(Color.WHITE);
								} else {
									c.setBackground(Color.LIGHT_GRAY);
								}
								return c;
							}

						});
				resultTable.setEnabled(false); // non - editable initial test
												// results table

				/*
				 * testresultTable.prepareRenderer(TableCellRenderer renderer,
				 * int row, int column){ Component returnComp =
				 * super.prepareRenderer(renderer, row, column); Color
				 * alternateColor = new Color(252,242,206); Color whiteColor =
				 * Color.WHITE; if (!returnComp.getBackground().equals
				 * (getSelectionBackground())){ Color bg = (row % 2 == 0 ?
				 * alternateColor : whiteColor); returnComp .setBackground(bg);
				 * bg = null; } return returnComp; };
				 */
				// System.out.println("Jagan Testing...."+rowCount+"..."+k);
				// rowCount++;
				rowCount++;
				System.out.println("Here we are ....\t" + jaganTest.size()
						+ "\n" + rowCount);
			}

			for (int row = 0; row < sut.getTs().getMatrix().size(); row++) {
				// testresultTable.insertRow(row, new
				// Object[]{Arrays.toString(sut.getTs().getMatrix().get(row)),testResults.get(row)});
			} // Obtaining information from SUTInfoReader.java ends
			statusBar.setMessage(projectName + ": Information");
			initialBuildBtn.setEnabled(true);
			openedAlready = true;
			tree.setSelectionPath(new TreePath(parameters));
		}

	}

	private void printSUT(SUT sut, int curCmbLen) {

		for (Combo cmb : sut.getSuspiciousCombos(curCmbLen)) {

			String susCombination = cmb.getRank() + ","
					+ printPN_PV(cmb, sut.getParameters())
					+ String.format("%f", cmb.getRankValue()) + ","
					+ String.format("%f", cmb.getEnvRankValue());
			// System.out.println("Testing....."+susCombination);
			suspiciousCombination.add(susCombination);
		}

		// if ( sut.getStatus() != SUT.SUTState.continuing){
		// if (sut.getSuspiciousCombos(len - 1).size() > 0) {
		/*
		 * int cnt = 0; for (int i = 1; i < len; cnt +=
		 * sut.getSuspiciousCombos(i++).size()) ; if (cnt > 0) {
		 * out.println("\n\nDerived combos:");
		 *
		 * for (int i = 1; i < len; i++) { if (sut.getSuspiciousCombos(i).size()
		 * > 0) {
		 *
		 * out.println("\n" + i + "-way suspicious combos");
		 * out.println("\nRank , \tCombo ,\tMin SoC  "); for (Combo cmb :
		 * sut.getSuspiciousCombos(i)) { out.format("%d , ", cmb.getRank());
		 * out.print(ComboManager.ToString(cmb, sut.getParameters()));
		 * out.format( " , %f \n", ComboManager.minSpcSubCmb(cmb,
		 * sut.getSuspiciousCombos(i + 1))); // ComboManager.maxRankSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1))); // ComboManager.maxSpcSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1)), // ComboManager.avgSpcSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1))); } } } }
		 */}

	// out.close();

	private String printPN_PV(Combo cmb, ArrayList<Parameter> parameters) {

		String output = "";
		String formattedOutput = "";
		for (edu.uta.cfl.data.Component cmp1 : cmb.getComponent()) {
			Parameter prm = parameters.get(parameters.indexOf(cmp1
					.getParameter()));
			output += "Parameter 1: " + prm.getName() + "\nParameter Value:  "
					+ prm.getValues().get(cmp1.getValue()) + "\n";
			formattedOutput += prm.getName() + ","
					+ prm.getValues().get(cmp1.getValue()) + ",";
		}

		return formattedOutput;
	}

	private void printTCList(ArrayList<int[]> tcList,
			ArrayList<Parameter> parameters) {
		System.out.println("Recommended Test Set - HEADER infromation\n");
		// printing header information
		for (Parameter prm : parameters) {
			System.out.println(prm.getName());
		}
		// printing row information
		int stater = 0;
		int i;
		String test;
		for (int[] tc : tcList) {
			test = "" + stater++ + " , ";
			for (i = 0; i < tc.length - 1; i++)
				test += parameters.get(i).getValues().get(tc[i]) + " , ";

			test += tc[tc.length - 1];
			recommendedTestSet.add(test);
			System.out.println(test + "\n" + recommendedTestSet.size());
		}
		Pattern values = Pattern.compile(",");
		String[] value;
		for (int a = 0; a < recommendedTestSet.size(); a++) {
			String[] tokens = values.split(recommendedTestSet.get(a));
			System.out.println(tokens.toString());
		}
	}

	protected void selectFile() {
		JFileChooser fileChooser = new JFileChooser();
		FileNameExtensionFilter textFilter = new FileNameExtensionFilter(
				"Text Files", "txt");
		fileChooser.setFileFilter(textFilter);
		fileChooser.addChoosableFileFilter(new TextFileFilter());
		int returnValue = fileChooser.showOpenDialog(null);
		if (returnValue == JFileChooser.APPROVE_OPTION) {
			selectedFile = fileChooser.getSelectedFile();
		}

	}

	protected void updateTreeRoot(String projectName) {
		// method to update the project name in the JTree
		DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
		DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
		root.setUserObject(projectName);
		model.nodeChanged(root);

	}

	// refactoring - moving the read file logic to this function for code
	// re-usability
	protected void loadInputFile(String inputFileLocation, String rts_Path,
			String sc_Path, String rts_FileName, String sc_FileName) {
		ArrayList<String> parameters_name = new ArrayList<String>();
		ArrayList<String> parameters_value = new ArrayList<String>();
		ArrayList<String> testResult_value = new ArrayList<String>();
		ArrayList<String> testResults = new ArrayList<String>();
		ArrayList<Parameter> parameters_initialForm = new ArrayList<Parameter>();

		// File file = f1.getSelectedFile();
		int icount = 1;
		inputTestFile = inputFileLocation;
		// newTCFileLocation = rts_Path + File.separator+rts_FileName+".txt";
		// susComboFileLocation = sc_Path + File.separator+sc_FileName+".txt";
		// masterFileLocation = rts_Path + File.separator+"masterFile.txt";

		// createMasterFile(masterFileLocation);
		SUT sut = new SUT();
		sut = (new SUTInfoReader(inputTestFile)).getSUT();
		// updateMasterFile(masterFileLocation, inputTestFile);
		// Obtaining information from SUTInfoReader.java file
		// starts

		// Parameters
		parameters_initialForm = sut.getParameters();
		for (Parameter p : parameters_initialForm) {
			parameters_name.add(p.getName());
			parameters_value.add(p.getValues().toString());
		}

		// Updating the Parameters table

		final String[] pnameArray = new String[2]; // Declaring string array
		pnameArray[0] = "Parameter Name"; // initializing the array elements
											// individually
		pnameArray[1] = "Parameter Value";

		pTable.setColumnCount(0);
		pTable.setRowCount(0);

		for (int col = 0; col < pnameArray.length; col++) {
			pTable.addColumn(pnameArray[col]);
		}

		for (int row = 0; row < parameters_name.size(); row++) {
			pTable.insertRow(row, new Object[] { parameters_name.get(row),
					parameters_value.get(row) });
		}

		// logic to update the UI of parameter table starts
		parameterTable.setDefaultRenderer(Object.class,
				new TableCellRenderer() {
					private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();

					@Override
					public Component getTableCellRendererComponent(
							JTable table, Object value, boolean isSelected,
							boolean hasFocus, int row, int column) {
						Component c = DEFAULT_RENDERER
								.getTableCellRendererComponent(table, value,
										isSelected, hasFocus, row, column);
						if (row % 2 == 0) {
							c.setBackground(Color.WHITE);
						} else {
							c.setBackground(Color.LIGHT_GRAY);
						}
						return c;
					}

				});
		parameterTable.setEnabled(false);
		// logic to update the UI of parameter table ends.
		// Updating the Constraints Table
		String[] columnName = { "Constraints" };
		cTable.setColumnCount(0);
		cTable.setRowCount(0);

		for (int col = 0; col < columnName.length; col++) {
			cTable.addColumn(columnName[col]);
		}

		for (int r = 0; r < sut.getConstraints().size(); r++) {
			cTable.insertRow(r, new Object[] { sut.getConstraints().get(r) });
		}
		constraintsTable.setEnabled(false);
		// initial test set with results
		testresultTable.setColumnCount(0);
		testresultTable.setRowCount(0);

		// Initial Test Result column calculation

		ArrayList<String> testDataColumnName = new ArrayList<String>();
		int count_new = 0;
		for (Parameter prm : parameters_initialForm)

		{
			// System.out.println("hehehehehe  "+count_new+"  the value is  "+prm.getName());
			testDataColumnName.add(count_new, prm.getName());
			count_new++;
		}

		testDataColumnName.add("Result");

		// calculating test data results
		int testResultSize = sut.getTs().getResult().size();

		for (int count = 0; count < testResultSize; count++) {

			testResult_value.add(sut.getTs().getResult().get(count).toString());
		}

		for (int count = 0; count < testResult_value.size(); count++) {
			String pass = "Pass";
			String fail = "fail";
			System.out.println("Count :" + count + "   Value :"
					+ testResult_value.get(count).toString());

			if (testResult_value.get(count).toString().equalsIgnoreCase("1")) {
				testResults.add(count, pass);
				System.out.println("testing: pass loop  " + testResults.size());
			} else if (testResult_value.get(count).toString()
					.equalsIgnoreCase("0")) {
				testResults.add(count, fail);
				System.out.println("testing:fail loop  " + testResults.size());
			}
		}

		System.out.println("testing:   " + testResults.size());
		// updating the table
		for (int col = 0; col < testDataColumnName.size(); col++) {
			testresultTable.addColumn(testDataColumnName.get(col));
		}

		ArrayList<String> testData = new ArrayList<String>();
		int testArray = sut.getTs().getMatrix().size();
		System.out.println("Jagan testing ..." + testArray + "\n"
				+ Arrays.toString(sut.getTs().getMatrix().get(1)));
		String a = Arrays.toString(sut.getTs().getMatrix().get(1));
		String arrayString[] = new String[testArray];
		System.out.println("Jagan testing .... round 2" + a);

		for (int i = 0; i < testArray; i++) {
			arrayString[i] = Arrays.toString(sut.getTs().getMatrix().get(i));
		}
		int rowCount = 0;

		for (String k : arrayString) {
			k = k.replace("[", "");
			k = k.replace("]", "");
			// int count_string =1;
			Pattern paramPattern = Pattern.compile(",");
			String[] tokens = paramPattern.split(k);
			ArrayList<String> jaganTest = new ArrayList<String>();

			for (int i = 0; i < tokens.length; i++) {
				jaganTest.add(tokens[i]);
				System.out.println("Printing data from ...." + jaganTest.size()
						+ "\n");

			}

			jaganTest.add(testResults.get(rowCount)); // adding
														// results
														// to
														// the
														// List

			/*
			 * System.out.println("\n==> Iterator Example...new") ;
			 * Iterator<String> testIterator1 = jaganTest.iterator();
			 * winitialBuildBtnhile (testIterator1.hasNext()) {
			 * System.out.println(testIterator1.next()); }
			 */
			// System.out.println("testing"+tokens.length);

			Vector<Object> row1 = new Vector<Object>();
			int count = 1;
			// logic to update the vector object
			// for(int i=0;i<tokens.length;i++)
			for (int i = 0; i < jaganTest.size(); i++) {
				// row1.add(tokens[i]);
				row1.add(jaganTest.get(i));
				System.out.println("Row #: " + count);
				// System.out.println(tokens[i]);
				count++;
			}

			testresultTable.addRow(row1);
			// added on 09/12/2014 - to
			resultTable.setDefaultRenderer(Object.class,
					new TableCellRenderer() {
						private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();

						@Override
						public Component getTableCellRendererComponent(
								JTable table, Object value, boolean isSelected,
								boolean hasFocus, int row, int column) {
							Component c = DEFAULT_RENDERER
									.getTableCellRendererComponent(table,
											value, isSelected, hasFocus, row,
											column);
							if (row % 2 == 0) {
								c.setBackground(Color.WHITE);
							} else {
								c.setBackground(Color.LIGHT_GRAY);
							}
							return c;
						}

					});
			resultTable.setEnabled(false);
			rowCount++;
			System.out.println("Here we are ....\t" + jaganTest.size() + "\n"
					+ rowCount);
		}

		for (int row = 0; row < sut.getTs().getMatrix().size(); row++) {
			// testresultTable.insertRow(row, new
			// Object[]{Arrays.toString(sut.getTs().getMatrix().get(row)),testResults.get(row)});
		}
		initialBuildBtn.setEnabled(true);
		openedAlready = true;

	}

	// refactoring - moving the read fileJTextArea logic to this function for
	// code
	// re-usability ends
	protected void updateMasterFile_results(int count,
			String masterFileLocation, String newTCFileLocation,
			String susComboFileLocation) {
		// Updating the master with iteration results

		try {
			File file = new File(masterFileLocation);

			FileWriter fWriter = new FileWriter(file.getAbsoluteFile(), true);
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.append("\n" + "Recommended Test Set : " + "\n"
					+ "   File Location:  " + newTCFileLocation + "\n" + "\n"
					+ "Suspicious Combinations: " + "\n" + "   File Location: "
					+ susComboFileLocation + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	protected void updateMasterFile(String masterFileLocation,
			String fileInformation, String rts_fileInfo, String sc_fileInfo,
			String projectName, String sourceFileLocation) {
		// Updating the Master File with Specification file information

		try {
			File file = new File(masterFileLocation);

			FileWriter fWriter = new FileWriter(file.getAbsoluteFile(), true);
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.append("\n" + "Project Name:    " + projectName
					+ "\n");
			bufferedWriter.append("\n" + "Source File Location:   "
					+ sourceFileLocation + "\n");
			bufferedWriter.append("\n" + "IPM + Initial Test Result:   "
					+ fileInformation + "\n");
			bufferedWriter.append("\n" + "Recommended Test Set : "
					+ rts_fileInfo + "\n");
			bufferedWriter.append("\n" + "Suspicious Combinations : "
					+ sc_fileInfo + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	protected void createMasterFile(String fileLocation) {
		// creating MasterFile with default information
		try {
			File file = new File(fileLocation);
			if (!file.exists()) {
				System.out.println("No File Found... creating new file");
				file.createNewFile();
			}

			System.out.println("testing:" + fileLocation);
			String timestamp = new java.text.SimpleDateFormat(
					"MM/dd/yyyy h:mm:ss a").format(new Date());
			FileWriter fWriter = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.write("# BEN Master File : " + timestamp + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected void loadMasterFile(String masterFile) {
		// to load contents in masterFile_textArea
		try {
			String textLine;
			FileReader fr = new FileReader(masterFile);
			BufferedReader reader = new BufferedReader(fr);
			masterFile_textArea.setText(null);
			while ((textLine = reader.readLine()) != null) {
				masterFile_textArea.append(textLine + "\n");
			}
		} catch (IOException ioe) {
			System.err.println(ioe);
			System.exit(1);
		}

	}

	protected void loadSourceCode(String sourceFileLocation) {
		// to load contents in Source code file area
		try {

			String textLine;
			FileReader fr = new FileReader(sourceFileLocation);
			BufferedReader reader = new BufferedReader(fr);
			sourceCodeFile_textArea.setText(null);
			while ((textLine = reader.readLine()) != null) {
				// sourceCodeFile_textArea.setText(textLine+"\n");
				sourceCodeFile_textArea.append(textLine + "\n");
			}

		} catch (IOException ioe) {
			System.err.println(ioe);
			System.exit(1);
		}
	}

	protected void displayInfo() {
		String msg = sut.getInitialDisplayMessage();
		// JOptionPane.showMessageDialog(frame, msg);
		System.out.println(msg);

	}

	protected void continueIteration() {
		// TODO Auto-generated method stub
		sut = new SUT();
		sut = (new SUTInfoReader(inputTestFile)).getSUT();
		curCmbLen = sut.getStrength();
		itr = 0;
		while (true) {
			String input;
			boolean add = false;
			do {
				int reply = JOptionPane
						.showConfirmDialog(
								null,
								"Press YES to add exeution status of new test cases, or Press CANCEL to exit:",
								"Want to Continue", JOptionPane.YES_NO_OPTION);
				// System.out.println
				// ("Press A to add exeution status of new test cases, or Press E to exit: ");
				if (reply != JOptionPane.YES_OPTION) {
					(new SUTInfoWriter(susComboFileLocation.substring(0,
							susComboFileLocation.lastIndexOf("\\") + 1)
							+ "cmp.txt")).printSuspiciousness(sut, curCmbLen);
					// System.exit(0);
					JOptionPane.getRootFrame().dispose();
				} else if (reply == JOptionPane.YES_OPTION) {
					add = true;

				}

			} while (!add);

		} // end of while
	}

	protected void modifyTree(int count) {

		child = new DefaultMutableTreeNode("Iteration " + count);
		DefaultMutableTreeNode susCombo = new DefaultMutableTreeNode(
				"Suspicious Combination");
		DefaultMutableTreeNode recommendedTestCases = new DefaultMutableTreeNode(
				"Recommended Test Case");
		DefaultMutableTreeNode susComponents = new DefaultMutableTreeNode(
				"Suspicious Components");
		treeModel.insertNodeInto(child, root, root.getChildCount());
		treeModel.insertNodeInto(susCombo, child, child.getChildCount());
		treeModel.insertNodeInto(recommendedTestCases, child,
				child.getChildCount());
		treeModel.insertNodeInto(susComponents, child, child.getChildCount());
		tree.setSelectionPath(new TreePath(recommendedTestCases));

	}

	protected void updateGUI(IterationResult itr) {
		// Table for new recommended test set
		rtsTable = new DefaultTableModel();
		ntc_JTable = new JTable(rtsTable);

		// table for suspicious combinations
		susTable = new DefaultTableModel();
		nsc_JTable = new JTable(susTable);

		// Table for Suspicious Components
		susComboTable = new DefaultTableModel();
		susComponent_JTable = new JTable(susComboTable);

		JScrollPane ntc_ScrollPane = new JScrollPane(ntc_JTable);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		ntc_Panel = new JPanel();
		ntc_Panel.setLayout(new BorderLayout());
		ntc_Panel.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel = new JPanel();
		nsc_Panel.setLayout(new BorderLayout());
		nsc_Panel.add(nsc_ScrollPane, BorderLayout.CENTER);
		nsc_Panel.add(susCombFilter, BorderLayout.SOUTH);

		// Panel for New Test Case
		susCombo_Panel = new JPanel();
		susCombo_Panel.setLayout(new BorderLayout());
		susCombo_Panel.add(susCombo_ScrollPane);

		loadNSC();
		loadNTC(itr);
		loadSusCombo(itr);

	}

	@SuppressWarnings("static-access")
	protected void initialLoad() {
		//

		CFL obj = new CFL();
		obj.processLoad(inputTestFile, susComboFileLocation, newTCFileLocation);
		sut = obj.sut; // added on 11/09/2014
		IterationResult itr1 = obj.iteration1;

		updateGUI(itr1);

	} // end of method

	protected void susComboHeader() {
		String[] susComboHeader = (new SusComboColumnHeader().getColumnName());

		for (int columnPos = 0; columnPos < susComboHeader.length; columnPos++) {
			susComboTable.addColumn(susComboHeader[columnPos]);
		}
	}

	protected void susComboRow(IterationResult itr) {

		ArrayList<String> suspiciousComponents = (new LoadSuspiciousComponents(
				itr, sut).getSuspiciousComponents());
		Pattern values = Pattern.compile(",");
		for (int a = 0; a < suspiciousComponents.size(); a++) {
			String[] tokens = values.split(suspiciousComponents.get(a));
			susComboTable.addRow(tokens);
		}

	}

	public void loadNTC(IterationResult itr) {

		loadRTSHeader();
		loadRecommendedTestSet(itr);
		//new TableDecorator(ntc_JTable).updateTableUI();
	}

	public void loadNSC() {
		susCombinationsColumnName();
		susCombinationRowData();
		//new TableDecorator(nsc_JTable).updateTableUI();
		nsc_JTable.setEnabled(false); // user can not edit the table
	}

	/**
	 * This method will update the column values
	 *
	 */
	public void susCombinationsColumnName() {
		ContextClass obj = new ContextClass(sut.getStrength()); // to be
																// refactored
																// later!
		String[] columnHeader = obj.getColumnHeader();
		susComboSize = columnHeader.length;
		susTable.setColumnCount(0);
		susTable.setRowCount(0);

		for (int columnPos = 0; columnPos < columnHeader.length; columnPos++) {
			susTable.addColumn(columnHeader[columnPos]);
		}
		resizeColumnWidth(nsc_JTable);

	}

	public void susCombinationRowData() {
		// new logic
		for (int row = 0; row < suspiciousCombination.size(); row++) {
			// String rowString = suspiciousCombination.get(row);
			// rowString = rowString.replaceAll("\\s+","(");
			// rowString = rowString.replaceAll("\\s+",")");
			// String[] items = rowString.split(",");
			// susTable.addRow(items);
		}
		Pattern values = Pattern.compile(",");

		for (int a = 0; a < suspiciousCombination.size(); a++) {
			String[] tokens = values.split(suspiciousCombination.get(a));
			susTable.addRow(tokens);
		}
		// Applying filter
		 susCombFilter.setTable(nsc_JTable);
		 susCombFilter.setAutoChoices(AutoChoices.ENABLED);
		 susCombFilter.setBackground(Color.LIGHT_GRAY);
		/*
		 * try { BufferedReader br = new BufferedReader(new FileReader(
		 * susCombinationFile));
		 *
		 * try { while ((columnStr = br.readLine()) != null) {
		 *
		 * if (columnStr.startsWith("2-way")) { //Variable Declaration
		 *
		 * ArrayList<String> rank1 = new ArrayList<String>(); ArrayList<String>
		 * p1Name = new ArrayList<String>(); ArrayList<String> p1Value = new
		 * ArrayList<String>(); ArrayList<String> p2Name = new
		 * ArrayList<String>(); ArrayList<String> p2Value = new
		 * ArrayList<String>(); ArrayList<String> soc1 = new
		 * ArrayList<String>(); ArrayList<String> soe1 = new
		 * ArrayList<String>(); ArrayList<String> finalOutput = new
		 * ArrayList<String>();
		 *
		 * String[] parameter1 = new String[300]; String[] parameter2 = new
		 * String[300];
		 *
		 * int i =0; while ((columnStr = br.readLine()) != null) {
		 *
		 *
		 * // Here, we remove the "(" and ")" from the output file columnStr =
		 * columnStr.replace("(", ""); columnStr = columnStr.replace(")", "");
		 * // now we have to split results based on the comma's // and add the
		 * // store them in the individual array list Pattern paramPattern =
		 * Pattern.compile(","); String[] tokens =
		 * paramPattern.split(columnStr); rank1.add(tokens[0].toString()); //
		 * storing the rank parameter1[i] = tokens[1]; // we will need to split
		 * // the parameter further // as parameter name and // parameter value
		 * parameter2[i] = tokens[2]; soc1.add(tokens[3].toString()); // storing
		 * the SoC // value soe1.add(tokens[4].toString()); // storing the SoE
		 * // value // We will have to seperate the parameter name and //
		 * parameter value from (p1=1) as "p1", "1" Pattern valuePattern =
		 * Pattern.compile("="); String[] parameter1_split =
		 * valuePattern.split(tokens[1]); String[] parameter2_split =
		 * valuePattern.split(tokens[2]); p1Name.add(parameter1_split[0]); //
		 * storing the parameter // 1 name p1Value.add(parameter1_split[1]); //
		 * storing the parameter // 1 value p2Name.add(parameter2_split[0]); //
		 * storing the parameter // 2 name p2Value.add(parameter2_split[1]); //
		 * storing the parameter // 2 value
		 *
		 * } int sizeOfList = rank1.size();
		 *
		 * for (int a = 0; a < sizeOfList; a++) { // Now, to store all the
		 * results in a single ArrayList<String> finalOutput.add((rank1.get(a) +
		 * "," + p1Name.get(a) + "," + p1Value.get(a) + "," + p2Name.get(a) +
		 * "," + p2Value.get(a) + "," + soc1.get(a) + "," + soe1.get(a))); }
		 *
		 * for(String v : finalOutput) { Pattern paramPattern =
		 * Pattern.compile(","); String[] tokens = paramPattern.split(v);
		 * ArrayList<String> finalResult = new ArrayList<String>(); for(int j
		 * =0;j<tokens.length;j++) { finalResult.add(tokens[j]); }
		 *
		 *
		 * Vector<Object> row1 = new Vector<Object>(); for (int j = 0; j <
		 * finalResult.size(); j++) { row1.add(finalResult.get(j));
		 * System.out.println(row1.capacity()+"::::"+finalResult.get(j));
		 *
		 * } System.out.println("Final vector size:"+row1.size());
		 * susTable.addRow(row1);
		 *
		 * //nsc_JTable.setAutoCreateRowSorter(true); // auto Sorting option
		 * enabled //TableRowFilterSupport.forTable(nsc_JTable).apply(); //
		 * calling External JAR to sort!
		 * //TableRowFilterSupport.forTable(nsc_JTable).searchable(true).apply();
		 * susCombFilter.setTable(nsc_JTable);
		 * susCombFilter.setAutoChoices(AutoChoices.ENABLED);
		 * susCombFilter.setBackground(Color.LIGHT_GRAY);
		 *
		 *
		 * }
		 *
		 * } // if- loop ends
		 *
		 * } //resizeColumnWidth(nsc_JTable);
		 *
		 * }
		 *
		 * catch (IOException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 *
		 * }
		 *
		 * catch (FileNotFoundException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */}

	public void loadRecommendedTestSet(IterationResult itr) {
		// new logic
		LoadRecommendedTestSet obj = new LoadRecommendedTestSet(itr, sut);
		ArrayList<String> tempList = obj.getRecommendedTestSet();

		for (int row = 0; row < tempList.size(); row++) {
			String rowString = tempList.get(row);
			rowString = rowString.replaceAll("\\s+", "");
			String[] items = rowString.split(",");
			rtsTable.addRow(items);
		}

		// Introducing the result column
		rtsTable.addColumn("Results");
		int numberOfColumns = rtsTable.getColumnCount();
		setUpResultColumn(ntc_JTable,
				ntc_JTable.getColumnModel().getColumn(numberOfColumns - 1));
		// end logic
		/*
		 * try { BufferedReader br = new BufferedReader(new
		 * FileReader(fileLocation));
		 *
		 * try { while ((columnStr = br.readLine()) != null) { if
		 * (columnStr.startsWith("Test #")) { while ((columnStr = br.readLine())
		 * != null) { Pattern paramPattern = Pattern.compile(","); String[]
		 * tokens = paramPattern.split(columnStr); String[] newTokens = new
		 * String[100]; Vector<Object> row1 = new Vector<Object>();
		 * Vector<String> newRow = new Vector<String>(); for (int i = 0; i <
		 * tokens.length; i++) { row1.add(tokens[i]); } //for(int a
		 * =0;a<recommendedTestSet.size();a++) //{ //newTokens =
		 * paramPattern.split(recommendedTestSet.get(a));
		 * //System.out.println(tokens.toString()); //}
		 *
		 *
		 *
		 * //rtsTable.addRow(newRow); resizeColumnWidth(ntc_JTable); }// while
		 * loops ends here
		 *
		 * }
		 *
		 * } //Introducing the result column rtsTable.addColumn("Results"); int
		 * numberOfColumns = rtsTable.getColumnCount();
		 * setUpResultColumn(ntc_JTable,
		 * ntc_JTable.getColumnModel().getColumn(numberOfColumns-1));
		 *
		 * }
		 *
		 * catch (IOException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 *
		 * } catch (FileNotFoundException e) { // TODO Auto-generated catch
		 * block e.printStackTrace(); }
		 *
		 * // TODO Auto-generated method stub
		 */}

	private void setUpResultColumn(JTable ntc_Table, TableColumn column) {
		// This method is used to introduce drop-down list options for RESULTS
		JComboBox comboBox = new JComboBox();
		comboBox.addItem("Pass");
		comboBox.addItem("Fail");
		column.setCellEditor(new DefaultCellEditor(comboBox));

		// Set up tool tips for the sport cells.
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setToolTipText("Click for combo box");
		column.setCellRenderer(renderer);
	}

	public void loadRTSHeader() {
		ArrayList<String> columnName = new ArrayList<String>();
		columnName.add("Test #");
		for (Parameter prm : sut.getParameters()) {
			columnName.add(prm.getName());
			// rtsTable.addColumn(prm.getName());
		}

		for (int i = 0; i < columnName.size(); i++) {
			rtsTable.addColumn(columnName.get(i));
		}
		System.out.println("Testing RTS column value:" + columnName.size());
		/*
		 * BufferedReader br; try { br = new BufferedReader(new
		 * FileReader(fileLocation));
		 *
		 * try { while ((columnStr = br.readLine()) != null) { if
		 * (columnStr.startsWith("Test #")) { System.out.println(columnStr +
		 * "column Header method"); Pattern paramPattern = Pattern.compile(",");
		 * String[] tokens = paramPattern.split(columnStr);
		 *
		 * System.out.println(tokens.length);
		 *
		 * System.out.println(tokens.length); for (int i = 1; i < tokens.length;
		 * i++) { System.out.println(tokens[i]); }
		 *
		 * rtsTable.setColumnCount(0); rtsTable.setRowCount(0); for (int
		 * columnPos = 0; columnPos < tokens.length; columnPos++) {
		 * rtsTable.addColumn(tokens[columnPos]); }
		 *
		 * resizeColumnWidth(ntc_JTable);
		 *
		 * } } } catch (IOException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 *
		 * } catch (FileNotFoundException e) { // TODO Auto-generated catch
		 * block e.printStackTrace(); }
		 */} // end of logic - loadColumnHeader();

	public void resizeColumnWidth(JTable table) {
		final TableColumnModel columnModel = table.getColumnModel();
		for (int column = 0; column < table.getColumnCount(); column++) {

			int width = 200; // Min width
			for (int row = 0; row < table.getRowCount(); row++) {
				TableCellRenderer renderer = table.getCellRenderer(row, column);
				Component comp = table.prepareRenderer(renderer, row, column);
				width = Math.max(comp.getPreferredSize().width, width);
			}
			columnModel.getColumn(column).setPreferredWidth(width);
		}
	}

}
